package jdbcTest;

import java.sql.*;

/**
 * Created by Administrator on 2017/9/11.
 */
public class ConnectionTest {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
         Class.forName("com.mysql.jdbc.Driver");
        Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3307/test","root","123456");
        if (conn != null){
            System.out.println("ok");
        }else{
            System.out.println("error");
        }
        Statement statement = conn.createStatement();
        String sql="select * from user";
        ResultSet set = statement.executeQuery(sql);
        while (set.next()){
            System.out.println(set.getString(1)+","+set.getString(2));
            User user = new User();

        }
        set.close();
        statement.close();
        conn.close();
    }
}
